import sys
sys.path.append(sys.path[0] + "/../interpreter")
from functionBinding import functionBinding
from functionDef import functionDef
from application import application
from Return import Return
from builtin import *
from varRef import varRef
from jsobject import *
from interpreter import interpreter
from endvals import *
from objectOps import *
from sequence import *
from conditionals import *
from sequence import *
from varBinding import *
from varMut import *
from customExceptions import *
from scope import scope

from astToLLVM import astToLLVM

#program = minus(mult(integer(6), integer(4)), integer(3))
#program = scope(ifthen(application("equals", [integer(10), integer(9)]), printOut(application("plus",[integer(1), integer(1)])), application("minus",[integer(1), integer(1)]) ))
#program = scope(whileloop(boolean(True),printOut(integer(1))))
#while with print
#program = scope(varBinding("a", integer(0),sequence([
#															whileloop(application("lessThan", [varRef("a"), integer(10)]),
#																	 scope(
#																	 		sequence([
#																	 					printOut(varRef("a")), 
#																	 					varMut("a", application("plus", [varRef("a"), integer(1)]))
#																	 					]
#																	 				)
#																	 		)
#																	 ),
#															ifthen(boolean(True), 
#															ifthen(application("equals", [varRef("a"), integer(10)]),
#																			boolean(True),
#																		 scope(printOut(stringval("a == 10"))),
																		 
#																		 boolean(True)
#																		 scope(printOut(stringval("a != 10"))) 
#																	 )
#																	])
#								)

#					)

#program = scope(varBinding("a",new("plus",[integer(1), integer(1)]), sequence([fieldMutation(varRef("a"), "b", integer(1)), printOut(fieldLookup(varRef("a"), "b"))]) ))

#program = scope(varBinding("a",new("plus",[integer(1), integer(1)]), sequence([fieldMutation(varRef("a"), "b", varRef("plus")), printOut(methodCall(varRef("a"),"b", [integer(1), integer(1)])) ])))

#test var mutation
#program = scope(varBinding("a", integer(1), sequence([printOut(varRef("a")), varMut("a", application("plus", [varRef("a"), integer(1)])),printOut(varRef("a"))])))

#test div
#program = div(integer(4), plus(integer(1), integer(1)))

#test minus
program = scope(minus(integer(2), flp(1.0)))

#program = scope(varBinding("a", integer(1), functionBinding([functionDef("f", [],scope(Return(application("plus", [integer(1), varRef("a")]))) )],application("f", []) )))
#program = scope(application("plus",[integer(1), integer(1)]))
#program = scope(varBinding("a", integer(1), plus(integer(1), varRef("a"))))
test = astToLLVM(program, True)
test.outputLLVM()
